package 牛客;

import java.util.*;

public class Niuke20212 {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        TreeMap<Integer, Integer> treemap = new TreeMap<Integer, Integer>(new Comparator<Integer>() {

            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        });
        Queue<Object> q = new PriorityQueue<>();
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] attacks = new int[n];
        int[] moneys = new int[n];
        for(int i =0 ;i <n;i++){
            attacks[i] = scanner.nextInt();
            treemap.put(attacks[i],i);
        }
        for(int i =0 ;i<n;i++){
            moneys[i] = scanner.nextInt();
        }
        int[] ans  = new int[n];
        int temp = 0;
        for(Object o :treemap.keySet()){
            q.add(treemap.get(o));
            temp += moneys[(int)treemap.get(o)];
            if(q.size()>k+1){
                Object poll = q.poll();
                temp -= (int)poll;
            }
            ans[(int)treemap.get(o)] = temp;

        }
        for(int i =0;i<n;i++){
            System.out.print(ans[i]);
            if(i<n-1){
                System.out.print(" ");
            }
        }
    }
}
